/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Trabalho3.RegrasPasswordChecker02;

import Trabalho3.RuleFactory;

/**
 *
 * @author geraldo
 */
public class RegraBonusMinusculas implements RuleFactory{
    String password;
    private final int FATOR_BONUS_MINUSCULAS = 2;

    public RegraBonusMinusculas(String password) {
        this.password = password;
    }

    @Override
    public int calcularRegra() {
        int total = this.somarMinusculas();
        return (total<password.length() && total>0)?(password.length() - total)* FATOR_BONUS_MINUSCULAS:0;
    
    }

    public int somarMinusculas() {
        int total = 0;
        for (char c : password.toCharArray()) {
            if (Character.isLowerCase(c)) {
                total++;
            }
        }
        return total;
    }
      
}
